#ifndef BMI088_RECEIVE_H
#define BMI088_RECEIVE_H

#include "struct_typedef.h"

/*  不用动 单纯给宏定义赋值而已    */
#define BMI088_ACC_RANGE_3G 0x00
#define BMI088_ACC_RANGE_6G 0x01
#define BMI088_ACC_RANGE_12G 0x02
#define BMI088_ACC_RANGE_24G 0x03
#define BMI088_GYRO_125 0x04
#define BMI088_GYRO_250 0x05
#define BMI088_GYRO_500 0x06
#define BMI088_GYRO_1000 0x07
#define BMI088_GYRO_2000 0x08

/*  需要设置成与C板一致   */
#define BMI088_ACC_RANGE_CHOICE BMI088_ACC_RANGE_6G//加速度计的量程 可选3G 6G 12G 24G；
#define BMI088_GYRO_RANG_CHOICE BMI088_GYRO_2000//陀螺仪的量程 125 250 500 1000 2000；

/*  加速度计    32768 * 1000 * 2^(ACC_RANGE + 1) */
#if(BMI088_ACC_RANGE_CHOICE == BMI088_ACC_RANGE_3G)
    #define BMI088_ACCEL_SEN 0.0008974358974f
#elif(BMI088_ACC_RANGE_CHOICE == BMI088_ACC_RANGE_6G)
    #define BMI088_ACCEL_SEN 0.00179443359375f
#elif(BMI088_ACC_RANGE_CHOICE == BMI088_ACC_RANGE_12G)
    #define BMI088_ACCEL_SEN 0.0035888671875f
#elif(BMI088_ACC_RANGE_CHOICE == BMI088_ACC_RANGE_24G)
    #define BMI088_ACCEL_SEN 0.007177734375f
#endif

/*  陀螺仪  */
#if(BMI088_GYRO_RANG_CHOICE == BMI088_GYRO_125)
    #define BMI088_GYRO_SEN 0.00013315805450396191230191732547673f
#elif(BMI088_GYRO_RANG_CHOICE == BMI088_GYRO_250)
    #define BMI088_GYRO_SEN 0.00013315805450396191230191732547673f
#elif(BMI088_GYRO_RANG_CHOICE == BMI088_GYRO_500)
    #define BMI088_GYRO_SEN 0.00026631610900792382460383465095346f
#elif(BMI088_GYRO_RANG_CHOICE == BMI088_GYRO_1000)
    #define BMI088_GYRO_SEN 0.00053263221801584764920766930190693f
#elif(BMI088_GYRO_RANG_CHOICE == BMI088_GYRO_2000)
    #define BMI088_GYRO_SEN 0.00106526443603169529841533860381f
#endif

/* BMI088数据结构 */
typedef __packed struct
{
        __packed struct
        {
			int16_t raw_x;	//寄存器原生数据
			int16_t raw_y;
			int16_t raw_z;

            float x;
			float y;
			float z;
		} accel;
		
        __packed struct
        {
			int16_t raw_x;	//寄存器原生数据
			int16_t raw_y;
			int16_t raw_z;

            float x;
			float y;
			float z;
        } gyro;
		
		int16_t raw_temp;	//寄存器原生数据
		float temp;
}BMI088_Data_t;

extern const BMI088_Data_t *get_BMI088_data_point(void);    //获取BMI088数据指针

extern void CAN_to_BMI088_accel(uint8_t data[8]);    //获取BMI088加速度计数据
extern void CAN_to_BMI088_gyro(uint8_t data[8]);     //获取BMI088陀螺仪数据

#endif
